package com.atguigu.jxc.controller;

import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
//http://localhost:8080/goods/listInventory
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @ResponseBody
    @PostMapping("listInventory")
    public Map<String,Object> list(Integer page, Integer rows, String codeOrName, Integer goodsTypeId){
        List<Goods> list = goodsService.selectList(page,rows,codeOrName,goodsTypeId);
        HashMap<String, Object> map = new HashMap<>();
        map.put("rows",list);
        map.put("total",list.size());
        return map;
    }



}
